package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IStoreOrderCartUpServiceDao;
import com.java110.dto.storeOrder.StoreOrderCartUpDto;
import com.java110.intf.cart.IStoreOrderCartUpInnerServiceSMO;
import com.java110.po.storeOrder.StoreOrderCartUpPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 挂单明细内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class StoreOrderCartUpInnerServiceSMOImpl extends BaseServiceSMO implements IStoreOrderCartUpInnerServiceSMO {

    @Autowired
    private IStoreOrderCartUpServiceDao storeOrderCartUpServiceDaoImpl;


    @Override
    public int saveStoreOrderCartUp(@RequestBody StoreOrderCartUpPo storeOrderCartUpPo) {
        int saveFlag = 1;
        storeOrderCartUpServiceDaoImpl.saveStoreOrderCartUpInfo(BeanConvertUtil.beanCovertMap(storeOrderCartUpPo));
        return saveFlag;
    }

     @Override
    public int updateStoreOrderCartUp(@RequestBody  StoreOrderCartUpPo storeOrderCartUpPo) {
        int saveFlag = 1;
         storeOrderCartUpServiceDaoImpl.updateStoreOrderCartUpInfo(BeanConvertUtil.beanCovertMap(storeOrderCartUpPo));
        return saveFlag;
    }

     @Override
    public int deleteStoreOrderCartUp(@RequestBody  StoreOrderCartUpPo storeOrderCartUpPo) {
        int saveFlag = 1;
        storeOrderCartUpPo.setStatusCd("1");
        storeOrderCartUpServiceDaoImpl.updateStoreOrderCartUpInfo(BeanConvertUtil.beanCovertMap(storeOrderCartUpPo));
        return saveFlag;
    }

    @Override
    public List<StoreOrderCartUpDto> queryStoreOrderCartUps(@RequestBody  StoreOrderCartUpDto storeOrderCartUpDto) {

        //校验是否传了 分页信息

        int page = storeOrderCartUpDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            storeOrderCartUpDto.setPage((page - 1) * storeOrderCartUpDto.getRow());
        }

        List<StoreOrderCartUpDto> storeOrderCartUps = BeanConvertUtil.covertBeanList(storeOrderCartUpServiceDaoImpl.getStoreOrderCartUpInfo(BeanConvertUtil.beanCovertMap(storeOrderCartUpDto)), StoreOrderCartUpDto.class);

        return storeOrderCartUps;
    }


    @Override
    public int queryStoreOrderCartUpsCount(@RequestBody StoreOrderCartUpDto storeOrderCartUpDto) {
        return storeOrderCartUpServiceDaoImpl.queryStoreOrderCartUpsCount(BeanConvertUtil.beanCovertMap(storeOrderCartUpDto));    }

    public IStoreOrderCartUpServiceDao getStoreOrderCartUpServiceDaoImpl() {
        return storeOrderCartUpServiceDaoImpl;
    }

    public void setStoreOrderCartUpServiceDaoImpl(IStoreOrderCartUpServiceDao storeOrderCartUpServiceDaoImpl) {
        this.storeOrderCartUpServiceDaoImpl = storeOrderCartUpServiceDaoImpl;
    }
}
